﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Sita.Data.Repositories;
using Sita.Entities;

namespace Sita.MainModule.Services
{
    public class EmployeeService
    {
        EmployeeRepository EmployeeRepository;

        public EmployeeService()
        {
            EmployeeRepository = new EmployeeRepository();
        }

        public IList<Employee> GetPaginatedEmployeesByBussinesUnitID(int businessUnitID, int pageIndex, int pageSize, string sortColumn, bool ascending, out int totalRows)
        {
            return EmployeeRepository.GetPaginatedByBusinessUnitID(businessUnitID, pageIndex, pageSize, sortColumn, ascending, out totalRows);
        }

        public int AddEmployee(Employee employee)
        {
            EmployeeRepository.Add(employee);

            EmployeeRepository.StoreContext.Commit();

            return employee.EmployeeID;
        }

        public Employee GetEmployeeByIDWithWO(int employeeID)
        {
            return EmployeeRepository.GetByIDWithWO(employeeID);
        }

        public Employee GetEmployeeByID(int employeeID)
        {
            return EmployeeRepository.GetByID(employeeID);
        }

        public bool ModifyEmployee(Employee employee)
        {
            EmployeeRepository.Modify(employee);

            EmployeeRepository.StoreContext.Commit();

            return true;
        }

        public bool DeleteEmployee(Employee employee)
        {
            EmployeeRepository.Delete(employee);

            EmployeeRepository.StoreContext.Commit();

            return true;
        }
    }
}
